<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCreditTradesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('credit_trades', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('buy_order_id')->comment('买入订单');
            $table->unsignedBigInteger('sell_order_id')->comment('卖出订单');
            $table->unsignedBigInteger('buyer_id')->comment('买方用户');
            $table->unsignedBigInteger('seller_id')->comment('卖方用户');
            $table->decimal('amount', 10, 2)->comment('成交数量');
            $table->decimal('price', 10, 2)->comment('成交单价');
            $table->decimal('total_price', 10, 2)->comment('成交总价');
            $table->timestamp('matched_at')->useCurrent()->comment('成交时间');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `credit_trades` comment '交易记录'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('credit_trades');
    }
}
